home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume24 / faxpax / part05 < prev    next >
Encoding:
Internet Message Format  |  1991-03-12  |  21.2 KB

  1. Subject:  v24i043:  Email fax-sending package, Part05/05
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 2a7a2215 e0e33eb1 bc674b5a ad46bc6c
  5.  
  6. Submitted-by: klaus u schallhorn <cnix!klaus>
  7. Posting-number: Volume 24, Issue 43
  8. Archive-name: faxpax/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  Howto.Install faxhost/faxfonts/diy_codep861.def
  17. #   faxhost/faxfonts/diy_ibmpc.def faxhost/faxfonts/diy_iso.def
  18. #   faxhost/faxlog.c faxhost/texttopbm.c sample.dot.faxrc
  19. # Wrapped by rsalz@litchi.bbn.com on Wed Mar 13 14:08:04 1991
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. echo If this archive is complete, you will see the following message:
  22. echo '          "shar: End of archive 5 (of 5)."'
  23. if test -f 'Howto.Install' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'Howto.Install'\"
  25. else
  26.   echo shar: Extracting \"'Howto.Install'\" \(3828 characters\)
  27.   sed "s/^X//" >'Howto.Install' <<'END_OF_FILE'
  28. XThis is faxpak - the "how to do" bit.
  29. X
  30. XYou need all the bits and pieces that come with it. You also need 
  31. XJef Poskanzer's pbmplus kit. If you have it installed on your system, 
  32. Xyou need to replace pbmtog3.c with the version that is included 
  33. Xin faxpak [there's only eol and eop differences fired up by a new 
  34. X"-sierra" option]. If you don't have pbmplus, it's been posted to
  35. Xcomp.sources.misc/vol9. I understand, Jef is currently [Feb '91] 
  36. Xin the process of preparing an updated pbmplus kit for posting.
  37. XIf you can't findt pbmplus locally, try varies archive servers [ic and
  38. Xukc are good places in the uk]. If all else fails, try mailing 
  39. Xjef@well.sf.ca.us.
  40. X
  41. X
  42. XUsing sierra type fax modems I found pbmtog3 too close to the standard 
  43. X- sierra type faxmodems are not, and fail therefore on page confirmation
  44. Xor multipage faxes to SOME fax machines on SOME g3 files. The brute force
  45. Xfix I made overcomes this. It's ugly too.
  46. X
  47. XRead readme. Run FaxConfig, to get faxconfig.h, FAXLIB/fax.config 
  48. Xand some other bits and pieces.
  49. X
  50. XIf you're on a sun, make. If there's no smoke [there shouldn't be],
  51. Xmake install
  52. Xelse
  53. X{
  54. X    If you're running some other system, you have to know how to
  55. X    get hardware flow control [termio(4) is a good place to start].
  56. X    If you don't have hardware flow ctl, you might try xon/xoff.
  57. X    I couldn't get it to work on a sun [don't tell me how it *should*
  58. X    be done, unless you get it to work in practice with a sierra
  59. X    type modem [it likes to hang up on me when I use xon/xoff]].
  60. X    I know how to drive printers and plotters with xon/xoff. At
  61. X    least they don't drop the phone line.
  62. X
  63. X    Until you've sorted out flow ctl, use wiring.c as a stand alone
  64. X    [and boy, you will feel alone] program. There's enough comments
  65. X    to guide you to insanity.
  66. X}
  67. XOnce you you have wiring.c working [flow ctl problem sorted out],
  68. Xyou have to have another look at faxconfig.h, FAXLIB/fax.config.
  69. X
  70. XYou also have to decide, who can and who cannot. Set up some files
  71. Xfax.allow or fax.deny in FAXLIB, specifying either who is allowed
  72. Xto fax, or who should be prevented from doing so [the logic, I think, 
  73. Xis the same used by cron].
  74. X
  75. XIn fax.config you also can enter dialing codes vs timezones. See
  76. Xexamples in FAXLIB/fax.config, if you want to send long distance
  77. Xfaxes at cheap rates only.
  78. X
  79. XDon't forget to put a binary of "fax" on each server. You need one
  80. Xfor each architecture supported. Keep a spare handy for those
  81. Xemergencies. 
  82. X
  83. XThen add a line to cron specifying when sendfax is to doodle. I
  84. Xhave it running once an hour from 1pm to 5pm, and twice an hour
  85. Xafter that till 6am. Enter another line for faxcleanup. This is
  86. Xa wire brush to free your disk of those faxes that absolutely won't
  87. Xgo. I also made an entry in /usr/bin-I-think/newsyslog, to start
  88. Xa new log file each week. I keep logs 4 weeks. If you set loglevel
  89. X[in FAXLIB/fax.config] to 9, these logs are huge.
  90. X
  91. XOn our spooler FAXLIB is owned by root, spool.fax runs suid and
  92. Xsgid root. The rest in FAXLIB is read/writeable by root only.
  93. X
  94. XThere are some stubs in various places for things I'm considering
  95. Xor planning for release 1.0. There commented out or undef'ed.
  96. XIgnore these for the time being.
  97. X
  98. XIf you get it to work on a non sun, please let me have the diffs or
  99. Xthe modifications. If you make a diykit.def file for a charset not
  100. Xcatered for in faxhost/faxfonts, please let me have a copy of that
  101. Xtoo.
  102. X
  103. XThis is, as specified in various places, only version 0.99. After
  104. Xgetting it to work at all, I will now shift the focus of attention
  105. Xto producing output that is pretty [I'm doing this in my spare time,
  106. Xso don't hold you breath].
  107. X
  108. XHave fun
  109. X
  110. Xklaus schallhorn, klaus@cnix.uucp
  111. X
  112. XYou can always mail me for the things I forgot. There are bound to be 
  113. Xsome. You can do what you want with faxpak, except trying to sell
  114. Xit. Don't make me start a price war. You're bound to lose.
  115. END_OF_FILE
  116.   if test 3828 -ne `wc -c <'Howto.Install'`; then
  117.     echo shar: \"'Howto.Install'\" unpacked with wrong size!
  118.   fi
  119.   # end of 'Howto.Install'
  120. fi
  121. if test -f 'faxhost/faxfonts/diy_codep861.def' -a "${1}" != "-c" ; then 
  122.   echo shar: Will not clobber existing file \"'faxhost/faxfonts/diy_codep861.def'\"
  123. else
  124.   echo shar: Extracting \"'faxhost/faxfonts/diy_codep861.def'\" \(1489 characters\)
  125.   sed "s/^X//" >'faxhost/faxfonts/diy_codep861.def' <<'END_OF_FILE'
  126. X#     char set layout ibm code page 861
  127. X#
  128. X#    note: this set does not contain 
  129. X#    the full ibm pc char set. If I'm not mistaken
  130. X#    only the pretty patterns are missing, though.
  131. X#    chars defined in iso, but not implemented on ibm pc hardware
  132. X#    have not been done.
  133. X#
  134. X# position in textfax{h,l}.font [decimal]
  135. X#    defined name in diykit.h
  136. X#            attempt at char description
  137. X128    Ccidilla    # C cidilla
  138. X129    uumlaut        # u umlaut
  139. X130    eac        # e'
  140. X131    acirc        # a^
  141. X132    aumlaut        # a umlaut
  142. X133    agr        # a`
  143. X134    adot        # a dot
  144. X135    ccidilla    # c cidilla
  145. X136    ecirc        # e^
  146. X137    eumlaut        # e umlaut
  147. X138    egr        # e`
  148. X139    Eth        # -D
  149. X140    eth        # small icelandic eth
  150. X141    thorn        # thorn
  151. X142    Aumlaut        # A umlaut
  152. X143    Aring        # A with ring above
  153. X144    Eac        # E'
  154. X145    ae        # ae
  155. X146    AE        # AE
  156. X147    ocirc        # o^
  157. X148    oumlaut        # o umlaut
  158. X149    Thorn        # cap. icelandic thorn
  159. X150    ucirc        # u^
  160. X### 151 ################ not defined in iso
  161. X152    yac        # y'
  162. X152    yumlaut        # y umlaut
  163. X153    Oumlaut        # O umlaut
  164. X154    Uumlaut        # U umlaut
  165. X155    cent        # cent sign
  166. X156    pound        # pound sign
  167. X157    yen        # yen sign
  168. X158    ptpc        # Pt as in ibmpc
  169. X159    fpc        # f as in ibmpc
  170. X160    aac        # a'
  171. X161    iac        # i'
  172. X162    oac        # o'
  173. X163    uac        # u'
  174. X164    Aac        # A'
  175. X165    Iac        # I'
  176. X166    Oac        # O'
  177. X167    Uac        # U'
  178. X168    invqu        # inverted ?
  179. X### 169
  180. X170    not        # not sign,
  181. X171    half        # 1/2
  182. X172    quarter        # 1/4
  183. X173    invexcl        # inverted !
  184. X174    angledleft    # <<
  185. X175    angledrite    # >>
  186. X#
  187. X225    germss        # small german letter sharp 's'
  188. X#
  189. X#
  190. X241    plusminus    # +-
  191. X#
  192. X246    div        # division sign
  193. X#
  194. X249    middot        # middle dot,
  195. X#
  196. X253    sup2        # superscript 2
  197. X#
  198. END_OF_FILE
  199.   if test 1489 -ne `wc -c <'faxhost/faxfonts/diy_codep861.def'`; then
  200.     echo shar: \"'faxhost/faxfonts/diy_codep861.def'\" unpacked with wrong size!
  201.   fi
  202.   # end of 'faxhost/faxfonts/diy_codep861.def'
  203. fi
  204. if test -f 'faxhost/faxfonts/diy_ibmpc.def' -a "${1}" != "-c" ; then 
  205.   echo shar: Will not clobber existing file \"'faxhost/faxfonts/diy_ibmpc.def'\"
  206. else
  207.   echo shar: Extracting \"'faxhost/faxfonts/diy_ibmpc.def'\" \(1494 characters\)
  208.   sed "s/^X//" >'faxhost/faxfonts/diy_ibmpc.def' <<'END_OF_FILE'
  209. X#     char set layout ibm pc type
  210. X#
  211. X#    note: this set does not contain 
  212. X#    the full ibm pc char set. If I'm not mistaken
  213. X#    only the pretty patterns are missing, though.
  214. X#    chars defined in iso, but not implemented on ibm pc hardware
  215. X#    have not been done.
  216. X#
  217. X# position in textfax{h,l}.font [decimal]
  218. X#    defined name in diykit.h
  219. X#            attempt at char description
  220. X128    Ccidilla    # C cidilla
  221. X129    uumlaut        # u umlaut
  222. X130    eac        # e'
  223. X131    acirc        # a^
  224. X132    aumlaut        # a umlaut
  225. X133    agr        # a`
  226. X134    adot        # a dot
  227. X135    ccidilla    # c cidilla
  228. X136    ecirc        # e^
  229. X137    eumlaut        # e umlaut
  230. X138    egr        # e`
  231. X139    iumlaut        # i umlaut
  232. X140    icirc        # i^
  233. X141    igr        # i`
  234. X142    Aumlaut        # A umlaut
  235. X143    Aring        # A with ring above
  236. X144    Eac        # E'
  237. X145    ae        # ae
  238. X146    AE        # AE
  239. X147    ocirc        # o^
  240. X148    oumlaut        # o umlaut
  241. X149    ogr        # o`
  242. X150    ucirc        # u^
  243. X151    ugr        # u`
  244. X152    yumlaut        # y umlaut
  245. X153    Oumlaut        # O umlaut
  246. X154    Uumlaut        # U umlaut
  247. X155    cent        # cent sign
  248. X156    pound        # pound sign
  249. X157    yen        # yen sign
  250. X158    ptpc        # Pt as in ibmpc
  251. X159    fpc        # f as in ibmpc
  252. X160    aac        # a'
  253. X161    iac        # i'
  254. X162    oac        # o'
  255. X163    uac        # u'
  256. X164    ntilde        # n~
  257. X165    Ntilde        # N~
  258. X166    femordind    # fem. ordinal ind., a_
  259. X167    mascordind    # masc. ordinal ind., a_
  260. X168    invqu        # inverted ?
  261. X#
  262. X170    not        # not sign,
  263. X171    half        # 1/2
  264. X172    quarter        # 1/4
  265. X173    invexcl        # inverted !
  266. X174    angledleft    # <<
  267. X175    angledrite    # >>
  268. X#
  269. X225    germss        # small german letter sharp 's'
  270. X#
  271. X227    pilcrow        # pilcrow, us paragraph
  272. X#
  273. X241    plusminus    # +-
  274. X#
  275. X246    div        # division sign
  276. X#
  277. X249    middot        # middle dot,
  278. X#
  279. X253    sup2        # superscript 2
  280. END_OF_FILE
  281.   if test 1494 -ne `wc -c <'faxhost/faxfonts/diy_ibmpc.def'`; then
  282.     echo shar: \"'faxhost/faxfonts/diy_ibmpc.def'\" unpacked with wrong size!
  283.   fi
  284.   # end of 'faxhost/faxfonts/diy_ibmpc.def'
  285. fi
  286. if test -f 'faxhost/faxfonts/diy_iso.def' -a "${1}" != "-c" ; then 
  287.   echo shar: Will not clobber existing file \"'faxhost/faxfonts/diy_iso.def'\"
  288. else
  289.   echo shar: Extracting \"'faxhost/faxfonts/diy_iso.def'\" \(2151 characters\)
  290.   sed "s/^X//" >'faxhost/faxfonts/diy_iso.def' <<'END_OF_FILE'
  291. X#    char set layout iso 8859/1
  292. X#
  293. X# position in textfax{h,l}.font [decimal]
  294. X#    defined name in diykit.h
  295. X#            attempt at character description
  296. X161    invexcl        # inverted !
  297. X162    cent        # cent sign
  298. X163    pound        # pound sign
  299. X164    currency    # currency sign
  300. X165    yen        # yen sign
  301. X166    brokenbar    # broken bar
  302. X167    paragraph    # paragraph sign
  303. X168    diaeresis    # diaeresis
  304. X169    copyrite    # copyright sign
  305. X170    femordind    # fem. ordinal ind., a_
  306. X171    angledleft    # <<
  307. X172    not        # not sign,
  308. X173    softhyphen    # soft hyphen, same as dash
  309. X174    tm        # registered trade mark
  310. X175    macron        # macron, high -
  311. X176    degree        # degree sign
  312. X177    plusminus    # +-
  313. X178    sup2        # superscript 2
  314. X179    sup3        # superscript 3
  315. X180    accacute    # accent acute'
  316. X181    micro        # micro sign
  317. X182    pilcrow        # pilcrow, us paragraph
  318. X183    middot        # middle dot,
  319. X184    cidilla        # cidilla,
  320. X185    sup1        # superscript 1
  321. X186    mascordind    # masc. ordinal ind., a_
  322. X187    angledrite    # >>
  323. X188    quarter        # 1/4
  324. X189    half        # 1/2
  325. X190    threequarts    # 3/4
  326. X191    invqu        # inverted ?
  327. X192    Agr        # A`
  328. X193    Aac        # A'
  329. X194    Acirc        # A^
  330. X195    Atilde        # A~
  331. X196    Aumlaut        # A umlaut
  332. X197    Aring        # A with ring above
  333. X198    AE        # AE
  334. X199    Ccidilla    # C cidilla
  335. X200    Egr        # E`
  336. X201    Eac        # E'
  337. X202    Ecirc        # E^
  338. X203    Eumlaut        # E umlaut
  339. X204    Igr        # I`
  340. X205    Iac        # I'
  341. X206    Icirc        # I^
  342. X207    Iumlaut        # I umlaut
  343. X208    Eth        # -D
  344. X209    Ntilde        # N~
  345. X210    Ogr        # O`
  346. X211    Oac        # O'
  347. X212    Ocirc        # O^
  348. X213    Otilde        # O~
  349. X214    Oumlaut        # O umlaut
  350. X215    multipl        # multiplication
  351. X216    ooblique    # O/
  352. X217    Ugr        # U`
  353. X218    Uac        # U'
  354. X219    Ucirc        # U^
  355. X220    Uumlaut        # U umlaut
  356. X221    Yac        # Y'
  357. X222    Thorn        # cap. icelandic thorn
  358. X223    germss        # small german letter sharp 's'
  359. X224    agr        # a`
  360. X225    aac        # a'
  361. X226    acirc        # a^
  362. X227    atidle        # a~
  363. X228    aumlaut        # a umlaut
  364. X229    adot        # a dot
  365. X230    ae        # ae
  366. X231    ccidilla    # c cidilla
  367. X232    egr        # e`
  368. X233    eac        # e'
  369. X234    ecirc        # e^
  370. X235    eumlaut        # e umlaut
  371. X236    igr        # i`
  372. X237    iac        # i'
  373. X238    icirc        # i^
  374. X239    iumlaut        # i umlaut
  375. X240    eth        # small icelandic eth
  376. X241    ntilde        # n~
  377. X242    ogr        # o`
  378. X243    oac        # o'
  379. X244    ocirc        # o^
  380. X245    otilde        # o~
  381. X246    oumlaut        # o umlaut
  382. X247    div        # division sign
  383. X248    ooblique    # o/
  384. X249    ugr        # u`
  385. X250    uac        # u'
  386. X251    ucirc        # u^
  387. X252    uumlaut        # u umlaut
  388. X253    yac        # y'
  389. X254    thorn        # thorn
  390. X255    yumlaut        # y umlaut
  391. END_OF_FILE
  392.   if test 2151 -ne `wc -c <'faxhost/faxfonts/diy_iso.def'`; then
  393.     echo shar: \"'faxhost/faxfonts/diy_iso.def'\" unpacked with wrong size!
  394.   fi
  395.   # end of 'faxhost/faxfonts/diy_iso.def'
  396. fi
  397. if test -f 'faxhost/faxlog.c' -a "${1}" != "-c" ; then 
  398.   echo shar: Will not clobber existing file \"'faxhost/faxlog.c'\"
  399. else
  400.   echo shar: Extracting \"'faxhost/faxlog.c'\" \(3865 characters\)
  401.   sed "s/^X//" >'faxhost/faxlog.c' <<'END_OF_FILE'
  402. X#include <stdio.h>
  403. X#include <fcntl.h>
  404. X#include <varargs.h>
  405. X#include <errno.h>
  406. X#include <time.h>
  407. X
  408. X#include "../faxconfig.h"
  409. X
  410. X/*
  411. X    logging and locking for faxpak
  412. X
  413. X    first released version 0.99 [desperado version]
  414. X    cleaned up Jan 22nd '91, 
  415. X    Copyright (C) 1991, klaus schallhorn, klaus@cnix.uucp
  416. X
  417. X    Permission to use, copy, modify, and distribute this software 
  418. X    and its documentation for any purpose and without fee is hereby 
  419. X    granted, provided that the above copyright notice appear in 
  420. X    all copies and that both that copyright notice and this permission 
  421. X    notice appear in supporting documentation. 
  422. X
  423. X    This software is provided "as is" without express or implied warranty.
  424. X*/
  425. X
  426. Xchar    lckname[256], logname[256];
  427. Xextern    int errno;
  428. Xextern    int blah;
  429. X
  430. X/*
  431. X    enter something in faxlog file, lock it to have exclusive
  432. X    access while we're writing
  433. X    unlock when done
  434. X*/
  435. X
  436. Xfax_log(va_alist)
  437. Xva_dcl
  438. X{
  439. X    va_list args;
  440. X    char *fmt;
  441. X    int db_flag;
  442. X    FILE *fp;
  443. X
  444. X    va_start(args);
  445. X    db_flag = va_arg(args, int);
  446. X    fmt = va_arg(args, char *);
  447. X
  448. X    if (db_flag == ERROR || (blah >= db_flag))
  449. X    {
  450. X        sprintf(lckname, "%s/FAX.LOG.LOCK", FAXLIB);
  451. X        sprintf(logname, "%s/FAX.LOG", FAXLIB);
  452. X
  453. X        if (mklock(lckname, 3, 15))
  454. X            return(ERROR);
  455. X
  456. X        if ((fp = fopen(logname, "a")) != NULL)
  457. X        {
  458. X            chmod(logname, FAXFMODE);
  459. X            timestamp(fp,(time_t)0L);
  460. X            if (db_flag == ERROR)
  461. X                fprintf(fp,"[%05d] %2d ",getpid(),errno);
  462. X            else fprintf(fp,"[%05d]    ",getpid());
  463. X            vfprintf(fp, fmt, args);
  464. X        }
  465. X
  466. X        fclose(fp);
  467. X        unlink(lckname);
  468. X    }
  469. X    va_end(args);
  470. X    return(0);
  471. X}
  472. X
  473. X/*
  474. X    same as fax_log, except we use an applications specific
  475. X    log file during transmission of fax as to not encounter
  476. X    any delays for waiting for a lock [we're on the phone now!].
  477. X
  478. X    fflushlog moves the contents of this temp file to the real
  479. X    log file after hangup
  480. X*/
  481. Xfax_tlog(va_alist)
  482. Xva_dcl
  483. X{
  484. X    va_list args;
  485. X    int db_flag;
  486. X    FILE *fp;
  487. X    char *fmt;
  488. X
  489. X    va_start(args);
  490. X
  491. X    db_flag = va_arg(args, int);
  492. X    fp = va_arg(args, FILE *);
  493. X    fmt = va_arg(args, char *);
  494. X
  495. X    if (fp && (db_flag == ERROR || (blah >= db_flag)))
  496. X    {
  497. X        timestamp(fp,(time_t)0L);
  498. X        if (db_flag == ERROR)
  499. X            fprintf(fp,"[%05d] %2d ",getpid(),errno);
  500. X        else fprintf(fp,"[%05d]    ",getpid());
  501. X        vfprintf(fp, fmt, args);
  502. X    }
  503. X    va_end(args);
  504. X    return(0);
  505. X}
  506. Xfflushlog(tlogname)
  507. Xchar *tlogname;
  508. X{
  509. X    FILE *in, *out;
  510. X    char buf[256];
  511. X
  512. X    sprintf(lckname, "%s/FAX.LOG.LOCK", FAXLIB);
  513. X    sprintf(logname, "%s/FAX.LOG", FAXLIB);
  514. X
  515. X    if (mklock(lckname, 4, 60))    /* wait up to a minute */
  516. X        return(ERROR);
  517. X
  518. X    if (((out = fopen(logname, "a")) != NULL)
  519. X        && ((in = fopen(tlogname, "r")) != NULL))
  520. X    {
  521. X        while (fgets(buf, 248, in) != NULL)
  522. X            if (fputs(buf, out) == EOF)
  523. X                return(ERROR);
  524. X        fflush(out);
  525. X        if (ferror(in) || ferror(out))
  526. X            return(ERROR);
  527. X        fclose(in);    /* if we have errors on one of these */
  528. X        fclose(out);    /* it's likely that fax_log will produce */
  529. X                /* errors as well, simply reboot ;-) */
  530. X        if (!unlink(lckname))
  531. X            return(0);
  532. X    }
  533. X    return(ERROR);
  534. X}
  535. X
  536. Xmklock(lockname,nap,max_secs)
  537. Xchar *lockname;
  538. Xint nap,max_secs;
  539. X{
  540. X    int i,l;
  541. X
  542. X    i=0;            /* wait till logfile is avail */
  543. X    while ((l = open(lockname, O_WRONLY | O_CREAT | O_EXCL, 0666)) == ERROR
  544. X        && errno == EEXIST)
  545. X    {
  546. X        if ((!max_secs) || (max_secs && (i == max_secs)))
  547. X            return(ERROR);
  548. X        sleep(nap);
  549. X        i += nap;
  550. X    }
  551. X    if (l > ERROR)
  552. X    {
  553. X        close(l);
  554. X        return(0);
  555. X    }
  556. X    return(ERROR);
  557. X}
  558. X
  559. Xtimestamp(fp,alt)
  560. XFILE *fp;
  561. Xtime_t alt;
  562. X{
  563. X    time_t t;
  564. X    struct tm *tml, *localtime();
  565. X
  566. X    if (alt)
  567. X        t = alt;
  568. X    else time(&t);
  569. X    tml = localtime(&t);
  570. X    ++tml->tm_mon;        /* jan is 0 */
  571. X
  572. X    fprintf(fp,"%02d.%02d.%2d %02d:%02d:%02d ",
  573. X        tml->tm_mday,tml->tm_mon,tml->tm_year,
  574. X        tml->tm_hour,tml->tm_min,tml->tm_sec);
  575. X}
  576. X
  577. X/*
  578. X    mainly used in spool.fax [I think], used to inform
  579. X    a user of his bad fortune
  580. X*/
  581. Xmailexit(s)
  582. Xchar *s;
  583. X{
  584. X    char buf[256];
  585. X
  586. X    if (*s)
  587. X    {
  588. X        sprintf(buf,"echo \"spool.fax, pid %05d: error while spooling\" | mail %s",
  589. X            getpid(),s);
  590. X        system(buf);
  591. X    }
  592. X    exit(1);
  593. X}
  594. END_OF_FILE
  595.   if test 3865 -ne `wc -c <'faxhost/faxlog.c'`; then
  596.     echo shar: \"'faxhost/faxlog.c'\" unpacked with wrong size!
  597.   fi
  598.   # end of 'faxhost/faxlog.c'
  599. fi
  600. if test -f 'faxhost/texttopbm.c' -a "${1}" != "-c" ; then 
  601.   echo shar: Will not clobber existing file \"'faxhost/texttopbm.c'\"
  602. else
  603.   echo shar: Extracting \"'faxhost/texttopbm.c'\" \(3379 characters\)
  604.   sed "s/^X//" >'faxhost/texttopbm.c' <<'END_OF_FILE'
  605. X#include <stdio.h>
  606. X#include <ctype.h>
  607. X#include "../faxconfig.h"
  608. X
  609. X/*
  610. X    texttopbm.c
  611. X
  612. X    crude frontent to fntwrite
  613. X
  614. X    first released version 0.99 [desperado version]
  615. X    cleaned up Jan 28nd '91,
  616. X    Copyright (C) 1991, klaus schallhorn, klaus@cnix.uucp
  617. X
  618. X    Permission to use, copy, modify, and distribute this software 
  619. X    and its documentation for any purpose and without fee is hereby 
  620. X    granted, provided that the above copyright notice appear in 
  621. X    all copies and that both that copyright notice and this permission 
  622. X    notice appear in supporting documentation. 
  623. X
  624. X    This software is provided "as is" without express or implied warranty.
  625. X*/
  626. X
  627. Xint    fax_mode=COARSE;
  628. Xchar    TEXTFONT[256], outname[256], tname[256];
  629. Xunsigned char inbuf[1024];
  630. Xchar    *strrchr();
  631. Xchar    *PGM;
  632. XFILE    *outfp;
  633. Xextern    int font_type;
  634. X
  635. Xmain(argc,argv)
  636. Xint argc;
  637. Xchar *argv[];
  638. X{
  639. X    FILE *fp = NULL;
  640. X    int i, x, y;
  641. X
  642. X    if ((PGM = strrchr(argv[0], '/')) != NULL)
  643. X        ++PGM;
  644. X    else PGM = argv[0];
  645. X
  646. X
  647. X    outname[0] = TEXTFONT[0] = '\0';
  648. X    for (i=1; i<argc; i++)
  649. X    {
  650. X        if (!strncmp(argv[i], "-h", 2))
  651. X            fax_mode = FINE;
  652. X        else if (!strncmp(argv[i], "-f", 2))
  653. X        {
  654. X            if (argv[i][2] == '/')
  655. X                strcpy(TEXTFONT, &argv[i][2]);
  656. X            else sprintf(TEXTFONT, "%s/%s", FAXLIB, &argv[i][2]);
  657. X        }
  658. X        else if (!strncmp(argv[i], "-i", 2))
  659. X        {
  660. X            if ((fp = fopen(&argv[i][2], "r")) == NULL)
  661. X            {
  662. X                fprintf(stderr,"%s: can't open %s\n",PGM,&argv[i][2]);
  663. X                exit(1);
  664. X            }
  665. X        }
  666. X        else if (!strncmp(argv[i], "-o", 2))
  667. X            strcpy(outname, &argv[i][2]);
  668. X    }
  669. X
  670. X    if (!TEXTFONT[0])
  671. X    {
  672. X        if (fax_mode == FINE)
  673. X            sprintf(TEXTFONT, "%s/%s", FAXLIB, FAXHFONT);
  674. X        else sprintf(TEXTFONT, "%s/%s", FAXLIB, FAXLFONT);
  675. X    }
  676. X
  677. X    if (fp == NULL)
  678. X    {
  679. X        if (isatty(fileno(stdin)))
  680. X        {
  681. X            fprintf(stderr,"%s [-high_res -ffont -ifile -ofile]\n",PGM);
  682. X            exit(2);
  683. X        }
  684. X        fp = stdin;
  685. X    }
  686. X
  687. X    if ((!outname[0]) && isatty(fileno(stdout)))
  688. X    {
  689. X        fprintf(stderr,"%s: need -ofile or redirection\n",PGM);
  690. X        exit(2);
  691. X    }
  692. X
  693. X    if (font_init(TEXTFONT))
  694. X        exit(3);
  695. X
  696. X    if (font_type == HP)
  697. X    {
  698. X        x = 2800;
  699. X        y = 3600;
  700. X    }
  701. X    else if (font_type == FINE)
  702. X    {
  703. X        x = 1800;
  704. X        y = 2200;
  705. X    }
  706. X    else
  707. X    {
  708. X        x = 1800;
  709. X        y = 1100;
  710. X    }
  711. X                /* 9 by 12 inches, big enough for A4 */
  712. X    if (mk_bm(x,y))        /* if we're using a 300 dpi bitmap */
  713. X        exit(4);    /* allows me to use any hp ljet font <= 30 pts */
  714. X                /* maybe even larger, but haven't tested that */
  715. X    exit(texttopbm(fp));
  716. X}
  717. Xtexttopbm(fp)
  718. XFILE *fp;
  719. X{
  720. X    int line, page, line_inc, line_max;
  721. X
  722. X    switch(font_type)
  723. X    {
  724. X    case HP:    line = line_inc = 50;    line_max = 3250;    break;
  725. X    case COARSE:    line = line_inc = 16;    line_max = 1040;    break;
  726. X    case FINE:    line = line_inc = 34;    line_max = 2080;    break;
  727. X    }
  728. X
  729. X    page = 0;
  730. X
  731. X    if (outname[0])
  732. X    {
  733. X        sprintf(tname,"%s.%d",outname,page);
  734. X        if ((outfp = fopen(tname, "w")) == NULL)
  735. X        {
  736. X            fprintf(stderr,"%s: can't create %s",PGM,tname);
  737. X            return(ERROR);
  738. X        }
  739. X        chmod(tname, FAXFMODE);
  740. X    } else outfp = stdout;
  741. X
  742. X    for (;;)
  743. X    {
  744. X        if (fgets(inbuf, 256, fp) == NULL)
  745. X            line = 9999;    /* first write out bitmap */
  746. X        else printstr(inbuf,line);
  747. X                /* 300 dpi / (6 lines per inch) = 50 dots */
  748. X        if ((line += line_inc) > line_max)
  749. X        {
  750. X            if (end_bm())
  751. X                return(ERROR);
  752. X            fclose(outfp);
  753. X
  754. X            if ((line > 9999) || (!outname[0])) /*done */
  755. X                return(0);
  756. X
  757. X            sprintf(tname,"%s.%d",outname,++page);
  758. X            if ((outfp = fopen(tname, "w")) == NULL)
  759. X            {
  760. X                fprintf(stderr,"%s: can't create %s",PGM,tname);
  761. X                return(ERROR);
  762. X            }
  763. X            chmod(tname, FAXFMODE);
  764. X            line = line_inc;
  765. X        }
  766. X    }
  767. X}
  768. END_OF_FILE
  769.   if test 3379 -ne `wc -c <'faxhost/texttopbm.c'`; then
  770.     echo shar: \"'faxhost/texttopbm.c'\" unpacked with wrong size!
  771.   fi
  772.   # end of 'faxhost/texttopbm.c'
  773. fi
  774. if test -f 'sample.dot.faxrc' -a "${1}" != "-c" ; then 
  775.   echo shar: Will not clobber existing file \"'sample.dot.faxrc'\"
  776. else
  777.   echo shar: Extracting \"'sample.dot.faxrc'\" \(168 characters\)
  778.   sed "s/^X//" >'sample.dot.faxrc' <<'END_OF_FILE'
  779. X# sample .faxrc
  780. X# no $HOME should be without one
  781. X#
  782. Xresolution low
  783. Xmail true
  784. Xnow false
  785. Xsave true
  786. Xretfax (000) 123 4567 [this is my mother in law, don't use at day time]
  787. END_OF_FILE
  788.   if test 168 -ne `wc -c <'sample.dot.faxrc'`; then
  789.     echo shar: \"'sample.dot.faxrc'\" unpacked with wrong size!
  790.   fi
  791.   # end of 'sample.dot.faxrc'
  792. fi
  793. echo shar: End of archive 5 \(of 5\).
  794. cp /dev/null ark5isdone
  795. MISSING=""
  796. for I in 1 2 3 4 5 ; do
  797.     if test ! -f ark${I}isdone ; then
  798.     MISSING="${MISSING} ${I}"
  799.     fi
  800. done
  801. if test "${MISSING}" = "" ; then
  802.     echo You have unpacked all 5 archives.
  803.     rm -f ark[1-9]isdone
  804. else
  805.     echo You still must unpack the following archives:
  806.     echo "        " ${MISSING}
  807. fi
  808. exit 0
  809. exit 0 # Just in case...
  810.